# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2005/03/12 15:38:27-07:00 kaos@sgi.com 
#   [IA64] Sanity check unw_unwind_to_user
#   
#   Signed-off-by: Keith Owens <kaos@sgi.com>
#   Signed-off-by: Tony Luck <tony.luck@intel.com>
# 
# arch/ia64/kernel/unwind.c
#   2005/03/12 15:26:25-07:00 kaos@sgi.com +4 -1
#   Sanity check unw_unwind_to_user
# 
diff -Nru a/arch/ia64/kernel/unwind.c b/arch/ia64/kernel/unwind.c
--- a/arch/ia64/kernel/unwind.c	2005-03-12 15:59:47 -08:00
+++ b/arch/ia64/kernel/unwind.c	2005-03-12 15:59:47 -08:00
@@ -1916,7 +1916,7 @@
 int
 unw_unwind_to_user (struct unw_frame_info *info)
 {
-	unsigned long ip;
+	unsigned long ip, sp;
 
 	while (unw_unwind(info) >= 0) {
 		if (unw_get_rp(info, &ip) < 0) {
@@ -1925,6 +1925,9 @@
 				   __FUNCTION__, ip);
 			return -1;
 		}
+		unw_get_sp(info, &sp);
+		if (sp >= (unsigned long)info->task + IA64_STK_OFFSET)
+			break;
 		/*
 		 * We don't have unwind info for the gate page, so we consider that part
 		 * of user-space for the purpose of unwinding.